package com.company;

import javax.lang.model.element.NestingKind;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Base64;

public class encryptionSecurity {
    public encryptionSecurity() {
        learnBase64();
        URLcode();
    }
    public void learnBase64(){
        String original = "Hello\u00ff编码测试";
        String b64 = Base64.getEncoder().encodeToString(original.getBytes(StandardCharsets.UTF_8));
        System.out.println(b64);
        String ori = null;
        try {
            ori = new String(Base64.getDecoder().decode(b64),"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        System.out.println(ori);
    }
    public void URLcode(){
        String original = "Hello\u00ff编码测试";
        String b64 = Base64.getEncoder().encodeToString(original.getBytes(StandardCharsets.UTF_8));
        System.out.println(b64);
        String ori = null;
        try {
            ori = new String(Base64.getDecoder().decode(b64),"UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        System.out.println(ori);
    }

}
